﻿Public Class FormNewCheckIn
    Dim DAReservation As New DSReservationTableAdapters.RESERVATIONTableAdapter

    Dim DARoom As New DSFloorManagemantTableAdapters.ROOMSTableAdapter
    Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        With cboRoom
            .DataSource = DARoom.GetData
            .ValueMember = "ROOM_ID"
            .DisplayMember = "ROOM_NAME"
            .SelectedIndex = -1
        End With
        ' Add any initialization after the InitializeComponent() call.

    End Sub
    Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
        SetEnglishLanguage()
        Me.Close()
    End Sub

    Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click
        SetEnglishLanguage()
        If DARoom.CheckRoomStatus(cboRoom.SelectedValue) > 0 Then
            MessageBox.Show("បន្ទប់ កំពុងភ្ញៀថសំរាក់ មិនអាចចុះឈ្មោះ បានទេ!", "Room", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End If
        If ValidateCombobox(cboRoom, "", ErrCheckIn) = False Then Exit Sub
        If ValidateDateField(DateCheckIn, "", ErrCheckIn) = False Then Exit Sub
        ' If ValidateTextField(txtCustomerName, "", ErrCheckIn) = False Then Exit Sub
        'If ValidateCombobox(CboSex, "", ErrCheckIn) = False Then Exit Sub
        'If ValidateTextField(TxtIDCard, "", ErrCheckIn) = False Then Exit Sub
        ' If ValidateDateField(TimeIn, "", ErrCheckIn) = False Then Exit Sub
        If MessageBox.Show("តើនាក់ ចង់រក្សាទុកភ្ញៀវចូលស្នាក់នៅ?", "Check In", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
            If DAReservation.NewReservationCheckIn(DateCheckIn.Value, TimeIn.Value, txtCustomerName.Text, CboSex.Text, TxtIDCard.Text, cboRoom.SelectedValue, 1, 1, 0, Now.Date, USER_NAME, TxtMoreInfo.Text, EmptyString(TxtPrepay.Text)) = 1 Then
                DARoom.UpdateRoomStatus(1, cboRoom.SelectedValue)
                Me.DialogResult = Windows.Forms.DialogResult.OK
            Else
                MessageBox.Show("Error save new reservation", "Check In", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End If
    End Sub
   
    Private Sub FormNewCheckIn_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub txtCustomerName_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCustomerName.Enter
        SetKhmerLanguage()
    End Sub

    Private Sub cboRoom_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboRoom.Enter
        SetEnglishLanguage()
    End Sub

    Private Sub DateCheckIn_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateCheckIn.Enter
        SetEnglishLanguage()
    End Sub

    Private Sub TxtIDCard_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtIDCard.Enter
        SetEnglishLanguage()
    End Sub

    Private Sub TimeIn_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimeIn.Enter
        SetEnglishLanguage()
    End Sub

    Private Sub TxtMoreInfo_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtMoreInfo.Enter
        SetKhmerLanguage()
    End Sub

    Private Sub CboSex_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CboSex.Enter
        SetEnglishLanguage()
    End Sub

    Private Sub TxtPrepay_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtPrepay.KeyPress
        SetDisableKeyString(e)
    End Sub
End Class